$.ajax({
		url:"../../user/alluser",
		type:"get",
		dataType:"json",
		success:function(data){
			
			var content = "";
			for (var i = 0; i < data.length; i++) {
				user=data[i];
				content +='<tr>'
						+'<td>'+user.uname+'</td>'
						+'<td>'+user.usex+'</td>'
						+'<td>'+user.uphone+'</td>'
						+'<td>'+user.score+'</td>'
						+'<td>暂时未写</td>';
				content	+='<td>'
					+'<a class="layui-btn layui-btn-sm" onclick="deleteRoom('+user.user_id+')"><i class="layui-icon"></i>删除</a>'
					+'</td>'
					+'</tr>';
			
				
				
				
			}
			
			$("#searchResult").html(content);
			
			
		}

		
		
		
	});



















function searchUser(){
	$.ajax({
		url:"../../user/search",
		type:"post",
		dataType:"json",
		data:{
			uname:$("#uname").val(),
			usex:$("#usex").val(),
			uphone:$("#uphone").val()
			
		},
		success:function(data){
			
			var content = "";
			for (var i = 0; i < data.length; i++) {
				user=data[i];
				content +='<tr>'
						+'<td>'+user.uname+'</td>'
						+'<td>'+user.usex+'</td>'
						+'<td>'+user.uphone+'</td>'
						+'<td>'+user.score+'</td>'
						+'<td>暂时未写</td>';
				content	+='<td>'
					+'<a class="layui-btn layui-btn-sm" onclick="deleteRoom('+user.user_id+')"><i class="layui-icon"></i>删除</a>'
					+'</td>'
					+'</tr>';
			
				
				
				
			}
			
			$("#searchResult").html(content);
			
			
		}

		
		
		
	});
	
	
	
}





function showFacility(room_id) {
	layui.use('layer', function() {
		var layer = layui.layer;
		//iframe层-父子操作
		b1s = layer.open({
			title: "设备设施",
			type: 2,
			area: ['70%', '60%'],
			scrollbar: true, //默认：true,默认允许浏览器滚动，如果设定scrollbar: false，则屏蔽
			maxmin: true,
			content: 'facilitys.html',
			success: function(layero, index) {
				var iframe = window['layui-layer-iframe' + index];
				iframe.child(room_id)
			}
		});
	});
}


///删除房间
function deleteRoom(room_id){
	$.ajax({
		url:"../../room/delete",
		type:"post",
		dataType:"json",
		
		data:{
			"room_id":room_id
		},
		success:function(data){
			if(data==0){
				alert("删除失败,房间内尚有客人");
				location.reload();
			}else{
				
				location.reload();
			}
			
			
		}
	});
}

